﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Text.RegularExpressions;
using System.Diagnostics;
using GCELibrary.Current;
using System.IO;
using ZF.BLL;
namespace gather.gt
{
    

    public abstract class gtBase1 : gtbase
    {
        public override void Init()
        {
            TypeName = this.GetType().ToString().Replace("gather.gt.", "") ;
            RegFile = TypeName + ".txt";
            base.Init();
        }
    }

    public class 二手市场 : gtBase1
    {
        public override string TypeName { get { return "二手市场"; } set { } }
        public override string[] Paths
        {
            get
            {
                return new string[] { "jiaju", "jiadian", "ershoubijibendiannao", "diannao", };
            }
        }
        public override InfoModel GetInfoModel(Match m)
        {
            InfoModel reuslt = null;

            try
            {
                var g = m.Groups;

                var areaId = GetAreaId(g[3].Value);

                reuslt = new InfoModel()
                {
                    title = g[1].Value,
                    price = g[2].Value.Convert<decimal>(0),
                    area = areaId,
                    body = g[4].Value,
                    phone = g[5].Value,
                    name = g[6].Value
                };
                Log(string.Format("成功--{0}--{1}--{2}", reuslt.title, reuslt.price, reuslt.area));
            }
            catch (Exception ex)
            {
                //_Debug(string.Format("{3}成功--{0}--{1}--{2}", reuslt.title, reuslt.price, reuslt.area, this.GetType()));
            }
            return reuslt;
        }
    }
    public class 二手市场1 : 二手市场
    {
 
        public override string[] Paths
        {
            get
            {
                return new string[] {"shuma", "fushixiaobaxuemao", "yingyouyunfu", "ruanjiantushu",};
            }
        }
    }
    public class 二手市场2 : 二手市场
    {

        public override string[] Paths
        {
            get
            {
                return new string[] {"xianzhilipin", "bangong", "wupinjiaohuan", "huishou" };
            }
        }
    }

    public class 车辆买卖 : gtBase1
    {
        public override string[] Paths
        {
            get
            {
                return new string[] { "ershouche",  "xinche","cheliangpeijian","zixingchemaimai", "motuoche" ,"diandongche" ,"pincheshangxiaban" };
            }
        }
        public override InfoModel GetInfoModel(Match m)
        {
            InfoModel reuslt = null;

            try
            {
                var g = m.Groups;

                var areaId = GetAreaId(g[3].Value);

                reuslt = new InfoModel()
                {
                    title = g[1].Value,
                    price = g[2].Value.Convert<decimal>()*10000,
                    area = areaId,
                    body = g[4].Value,
                    phone = g[5].Value,
                    name = g[6].Value
                };
                Log(string.Format("成功--{0}--{1}--{2}", reuslt.title, reuslt.price, reuslt.area));
            }
            catch (Exception ex)
            {
                //_Debug(string.Format("{3}成功--{0}--{1}--{2}", reuslt.title, reuslt.price, reuslt.area, this.GetType()));
            }
            return reuslt;
        }
    }
    public abstract class 生活 : gtBase1
     {
        public override string RegFile
        {
            get
            {
               return "生活.txt";
            }
            set
            {
                base.RegFile = value;
            }
        }
        public override InfoModel GetInfoModel(Match m)
        {
            InfoModel reuslt = null;

            try
            {
                var g = m.Groups;

                var areaId = GetAreaId(g[3].Value);
                if (areaId == 0) return null;
                var price = g[2].Value;
                if (price == "面议")
                    price = "0";
                else
                    price=price.Replace("元", "");
                reuslt = new InfoModel()
                {
                    title = g[1].Value,
                    price = price.Convert<decimal>(0),
                    area = areaId,
                    name = g[4].Value,
                    phone = g[5].Value,
                    body = g[6].Value,
                };
                Log(string.Format("成功--{0}--{1}--{2}", reuslt.title, reuslt.price, reuslt.area));
            }
            catch (Exception ex)
            {
                //_Debug(string.Format("{3}成功--{0}--{1}--{2}", reuslt.title, reuslt.price, reuslt.area, this.GetType()));
            }
            return reuslt;
        }
     }
    
    public class 搬家装修 : 生活
    {
        public override string[] Paths { get { return new string[] { "banjia", "zhuangxiu" }; } }
    }
    public class 家居维修 : 生活
    {
        public override string[] Paths { get { return new string[] { "jiajuweixiu" }; } }
    }
    public class 生活配送 : 生活
    {
        public override string[] Paths { get { return new string[] { "shenghuopeisong" }; } }
    }
    public class 家电维修 : 生活
    {
        public override string[] Paths { get { return new string[] { "jiadianweixiu" }; } }
    }
    public class 鲜花礼品 : 生活
    {
        public override string[] Paths { get { return new string[] { "yuanyizhiwu" }; } }
    }
    public class 家政家教 : 生活
    {
        public override string[] Paths { get { return new string[] { "jiazheng" }; } }
    }
    public class 保洁保养 : 生活
    {
        public override string[] Paths { get { return new string[] { "baojie" }; } }
    }
    public class 娱乐餐饮 : 生活
    {
        public override string[] Paths { get { return new string[] { "yulecanyin" }; } }
    }


   
    public class 物流货运 : 生活
    {
        public override string[] Paths { get { return new string[] { "wuliu", "kuaidi" }; } }
    }


    public class 交友征婚 : gtBase1
    {
        public override string[] Paths { get { return new string[] { "jiaoyou7", "jiaoyou6", "jiaoyou4", "jiaoyou5" }; } }
        public override InfoModel GetInfoModel(Match m)
        {
            InfoModel reuslt = null;

            try
            {
                var g = m.Groups;

                var areaId = GetAreaId(g[2].Value);
                if (areaId == 0) return null;
                var body = string.Format("交友条件:<br />{0}<br /><br />个人描述:<br />{1}", g[6].Value, g[7].Value);
                reuslt = new InfoModel()
                {
                    title = g[1].Value,
                    name = g[3].Value,
                    qq = g[4].Value,
                    email = g[5].Value,
                    price = -1,
                    area = areaId,
                    body = body,
                };
                Log(string.Format("成功--{0}--{1}--{2}", reuslt.title, reuslt.price, reuslt.area));
            }
            catch (Exception ex)
            {
                //_Debug(string.Format("{3}成功--{0}--{1}--{2}", reuslt.title, reuslt.price, reuslt.area, this.GetType()));
            }
            return reuslt;
        }
    }





    public class InfoModel
    {
        public decimal price;
        public string title;
        public string name;
        public string phone;
        public string body;
        public string date;
        public int area;
        public string key;
        public string type;
        public string email;
        public string qq;
    }

}
